
#include "nane/WindowSystem/WindowSystem.h"
#include "nane/WindowSystem/WindowSystemImpl_.h"
#include "nane/WindowSystem/WindowImpl_.h"
#include "nane/core/assert.h"
#include "nane/core/log.h"


namespace nane 
{
    ////////////////////////////////////////////////////////////////////////////////////////////////
    WindowSystem::WindowSystem()
        : SubSystem<IWindowSystem>( new Implementation() )
        , m( static_cast<Implementation*>(SubSystem<IWindowSystem>::m) )
    {
    
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////
    WindowSystem::~WindowSystem()
    {
        Shutdown();
        delete m;
        m = NULL;
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////
    Window WindowSystem::CreateWindow( const char* _title, uint32 _width, uint32 _height, uint32 _posX, uint32 _posY )
    {
        NANE_ASSERT_RV( m->interface != NULL, "WindowSystem must be initialized", NullPtr );
        Window::Implementation* windowImpl = NULL;
        IWindow* windowInterface = m->interface->CreateWindow(_title, _width, _height, _posX, _posY);
        if( windowInterface != NULL )
        {
            windowImpl = new Window::Implementation(m, windowInterface);
        }
        return Window(windowImpl);
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////
    uint32 WindowSystem::GetScreenWidth()
    {
        NANE_ASSERT_RV( m->interface != NULL, "WindowSystem must be initialized", 0 );
        return m->interface->GetScreenWidth();
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////
    uint32 WindowSystem::GetScreenHeight()
    {
        NANE_ASSERT_RV( m->interface != NULL, "WindowSystem must be initialized", 0 );
        return m->interface->GetScreenHeight();
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////
}   // namespace nane
